package com.leyou.auth.feign;

import com.leyou.auth.schedule.AppTokenSchedule;
import com.leyou.common.constants.LyConstants;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * User: ycs
 * Date: 2020/9/2
 * Time: 19:41
 * Description: Feign服务调用拦截器
 *
 * @author: ycs
 */
@Component
public class AuthFeignInterceptor implements RequestInterceptor {
    @Autowired
    private AppTokenSchedule appTokenSchedule;
    @Override
    public void apply(RequestTemplate requestTemplate) {
        //设置请求头
        requestTemplate.header(LyConstants.APP_TOKEN_HEADER,appTokenSchedule.getToken());
    }
}
